<template>
  <div>
    <h1>{{ msg }}</h1>
    <h1>{{ userName + 1 }}</h1>
    <button @click="getVal">传给父组件的值</button>
  </div>
</template>

<script>
export default {
  name: "son",
  data() {
    return {
      msg: "子组件模板显示的内容",
      age:'18',
    };
  },
  methods: {
    getVal(){
      console.log("进入方法");
      this.$emit('change1',this.age);
    }
  },
  props: ["userName"],
};
</script>

<style>
</style>